package routes

import (
	"soma-server/controller/system"
	"soma-server/middleware"

	"github.com/gin-gonic/gin"
)

// 注册用户路由
func InitUserRoutes(r *gin.RouterGroup, authMiddleware *middleware.JWTMiddleware) gin.IRoutes {
	userController := controller.NewUserController()
	router := r.Group("/user")
	// 开启jwt认证中间件
	router.Use(authMiddleware.JWTAuthMiddleware())
	// 开启casbin鉴权中间件
	router.Use(middleware.CasbinMiddleware())
	{
		// 获取用户信息
		router.GET("/info", userController.GetUserInfo)
		// 获取用户列表
		router.POST("/list", userController.GetUsers)
		// 更新用户密码
		router.PUT("/changePwd", userController.ChangePwd)
		// 创建用户信息
		router.POST("/create", userController.CreateUser)
		// 更新用户信息
		router.PUT("/update/:userId", userController.UpdateUserById)
		// 删除用户信息
		router.DELETE("/delete/batch", userController.BatchDeleteUserByIds)
	}
	return r
}
